/**
 * 
 */
package net.looker.monitor.checker;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Logger;

import net.looker.data.News;
import net.looker.monitor.modifier.DeleteModifier;
import net.looker.monitor.modifier.DispatcherManager;
import net.looker.monitor.schdule.NewsManager;



/**
 * 删除新闻检查器
 * @author solosky
 *
 */
public class DeleteChecker extends Checker
{
	
	/**
	 * 构造函数
	 * @param newsManager
	 */
	public DeleteChecker(NewsManager newsManager) 
	{
		super(newsManager);
	}

	/* (non-Javadoc)
	 * @see net.looker.news.site.category.checker.Checker#match()
	 */
	@Override
	public void check()
	{
		//检查当前的新闻列表，和以前的新闻列表相比
		//如果当前新闻没有，而以前的新闻列表有，则该新闻已经删除
		Iterator <News> it = newsManager.getLastNewsList().iterator();
		News lastNews = null;
		while (it.hasNext())
		{
			lastNews = it.next();
			if (newsManager.getCurNews(lastNews.getNewsHash())==null)
			{
				Logger.getLogger("looker").info("删除新闻："+lastNews.toString());
				DispatcherManager.delete(new DeleteModifier(lastNews));
			}
		}
	}

}
